package com.zqx.mediator.client;

import com.zqx.mediator.specificcomponent.*;
import com.zqx.mediator.specificmediator.ConcreteMediator;
import com.zqx.mediator.specificmediator.SubConcreteMediator;

public class Client {

    public static void main(String[] args) {
        //定义中介者对象
        //ConcreteMediator mediator;
        //mediator = new ConcreteMediator();

        //用新增具体中介者定义中介者对象
        SubConcreteMediator mediator;
        mediator = new SubConcreteMediator();
        //定义同事对象
        Button addBT = new Button();
        List list = new List();
        ComboBox cb = new ComboBox();
        TextBox userNameTB = new TextBox();
        Label label = new Label();//扩展同事对象

        addBT.setMediator(mediator);
        list.setMediator(mediator);
        cb.setMediator(mediator);
        userNameTB.setMediator(mediator);
        label.setMediator(mediator);//扩展

        mediator.addButton = addBT;
        mediator.list = list;
        mediator.cb = cb;
        mediator.userNameBox = userNameTB;
        mediator.label = label;//扩展

        addBT.changed();
        System.out.println("==============");
        list.changed();
    }
}
